package com.wuyunonline.tracelog.config;

import com.wuyunonline.tracelog.interceptor.TraceLogWebMvcInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * springMVC 添加traceId拦截器
 * @author wuyun
 */
@Configuration
public class TraceLogWebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(mvcInterceptor()).addPathPatterns("/**");
    }

    @Bean
    public TraceLogWebMvcInterceptor mvcInterceptor() {
        return new TraceLogWebMvcInterceptor();
    }

}